<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"  
                xmlns:h="http://java.sun.com/jsf/html"  
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                template="./../templates/TCubeStaffTemplate.xhtml">
 
    <ui:define name="nav">
        <f:view beforePhase="#{staffEditAccountManagedBean.initView}" >
        </f:view>
    </ui:define>

    <ui:define name="content">
        <h:form id="editStaffDetails">
            <!-- LOCALIZATION -->
            <!-- this selectedLocale menu must always be at the top of the form -->
            <h:selectOneMenu id="selectedLocale" value="#{indexManagedBean.selectedLocale}">
                <f:selectItem itemLabel="Select Language" itemValue="" />
                <f:selectItems value="#{enumLanguage.listItems}" />

                <p:ajax update="staffDetail
                                statusMessages
                                tabStaffAccountInfo
                                tabStaffCorporateInfo
                                tabStaffPersonalInfo
                                accountStaffUsernameLabel
                                accountStaffCurrentPasswordLabel
                                accountStaffNameLabel
                                accountStaffGenderLabel
                                accountStaffBirthdateLabel
                                accountStaffCountryLabel
                                accountStaffLanguageLabel
                                accountStaffDeptLabel
                                accountStaffJobPositionLabel
                                accountStaffJoinDateLabel
                                accountStaffAccessLabel
                                accountStaffEditButton" 
                        listener="#{indexManagedBean.selectedLocaleValueChangeListener}" />
            </h:selectOneMenu>
            <!-- this end selectedLocale menu must always be at the top of the form -->
            <!-- END LOCALIZATION -->
            
            <p:panel id="staffDetail" header="#{bundle['staff.header.panel']}"  >
                <p:messages id="statusMessages" />
                
                <p:tabView id="tabEditStaffEdit" dynamic="false">

                    <p:tab id="tabStaffAccountInfo" title="#{bundle['staff.accountinfo.tab']}">
                        <h:panelGrid columns="3" cellpadding="5">
                            <h:outputLabel id="accountStaffUsernameLabel" value="#{bundle['staff.username.label']}" style="font-weight: bold"/>
                            <h:outputText id="username" value="#{staffEditAccountManagedBean.username}" />
                            <p:message for="username" />

                            <h:outputLabel id="accountTouristCurrentPasswordLabel" value="#{bundle['staff.currentpassword.label']}" style="font-weight: bold"/>
                            <p:password id="currpassword" value="#{staffEditAccountManagedBean.currentPassword}" feedback="false" minLength="6" required="true" requiredMessage="staff.currentpassword.required" > 
                                <f:validateLength minimum="6"/>
                            </p:password>
                            <p:message for="currpassword" />
                            
                            <h:outputLabel id="accountTouristNewPasswordLabel" value="#{bundle['staff.newpassword.label']}" style="font-weight: bold"/>
                            <p:password id="newpassword" value="#{staffEditAccountManagedBean.newPassword}" feedback="true" minLength="6" required="true" requiredMessage="staff.newpassword.required" validatorMessage="#{bundle['staff.password.validatorLength']}"> 
                                <f:validateLength minimum="6"/>
                            </p:password>
                            <p:message for="newpassword" />

                            <h:outputLabel id="accountTouristConfirmPasswordLabel" value="#{bundle['staff.confirmpassword.label']}" style="font-weight: bold" />
                            <p:password id="confirmpassword" value="#{staffEditAccountManagedBean.confirmPassword}" feedback="true" minLength="6" required="true" requiredMessage="#{bundle['staff.confirmpassword.required']}" >
                                <f:validateLength minimum="6"/>
                            </p:password>
                            <p:message for="confirmpassword" />

                            <h:outputLabel id="accountTouristLanguageLabel" value ="#{bundle['staff.languagepreferred.label']}" style="font-weight: bold"/>
                            <h:selectOneMenu id="language" value="#{staffEditAccountManagedBean.locale}" required="true" requiredMessage="#{bundle['staff.languagepreferred.required']}">
                                <f:selectItems value="#{enumLanguage.listItems}"/>
                            </h:selectOneMenu>
                            <p:message for="language"/>
        
                            <h:outputLabel id="accountTouristEmailLabel" value ="#{bundle['staff.email.label']}" style="font-weight: bold"/>
                            <h:outputText id="email" value="#{staffEditAccountManagedBean.email}" />
                            <p:message for="email"/>
                            
                        </h:panelGrid>
                    </p:tab>
                    
                    <p:tab id="tabStaffCorporateInfo" title="#{bundle['staff.corporateinfo.tab']}">
                        <h:panelGrid columns="3" cellpadding="5">
                            
                            <h:outputLabel id="accountStaffDeptLabel" value ="#{bundle['staff.department.label']}" style="font-weight: bold"/>
                            <h:outputText id="dept" value="#{staffEditAccountManagedBean.department}" />
                            <p:message for="dept"/>

                            <h:outputLabel id="accountStaffJobPositionLabel" value ="#{bundle['staff.jobposition.label']}" style="font-weight: bold"/>
                            <h:outputText id="jobposition" value="#{staffEditAccountManagedBean.jobPosition}" />
                            <p:message for="jobposition"/>
                            
                            <h:outputLabel id="accountStaffJoinDateLabel" value ="#{bundle['staff.joindate.label']}" style="font-weight: bold" />
                            <h:outputText id="joindate" value="#{staffEditAccountManagedBean.joinDate}" />
                            <p:message for="joindate"/>

                            <h:outputLabel id="accountStaffAccessLabel" value ="#{bundle['staff.accessrights.label']}" style="font-weight: bold" />
                            <p:dataList id="accessRights" value="#{staffEditAccountManagedBean.accessRightsList}" var="accessRight" itemType="square" >             
                                <p:column>
                                    <h:outputText value="#{accessRight}" />
                                </p:column>
                            </p:dataList>
                            <p:message for="accessRights"/>
                            
                        </h:panelGrid>
                    </p:tab>

                    <p:tab id="tabStaffPersonalInfo" title="#{bundle['staff.personalinfo.tab']}">
                        <h:panelGrid  columns="3" cellpadding="5">
                            <h:outputLabel id="accountStaffNameLabel" value="#{bundle['staff.name.label']}" style="font-weight: bold"/>
                            <h:outputLabel id="name" value="#{staffEditAccountManagedBean.name}" />
                            <p:message for="username" />

                            <h:outputLabel id="accountStaffGenderLabel" value="#{bundle['staff.gender.label']}" style="font-weight: bold"/>
                            <h:outputLabel id="gender" value="#{staffEditAccountManagedBean.gender}" />
                            <p:message for="gender"/>

                            <h:outputLabel id="accountStaffBirthdateLabel" value ="#{bundle['staff.birthdate.label']}" style="font-weight: bold"/>
                            <h:outputText id="birthdate" value="#{staffEditAccountManagedBean.birthdate}" />
                            <p:message for="birthdate"/>

                            <h:outputLabel id="accountTouristCountryLabel" value ="#{bundle['staff.country.label']}" style="font-weight: bold"/>
                            <h:selectOneMenu id="country" value="#{staffEditAccountManagedBean.country}" required="true" requiredMessage="#{bundle['staff.country.required']}" >
                                <f:selectItems value="#{enumCountry.listItems}"/>
                            </h:selectOneMenu>
                            <p:message for="country"/>
                            
                            <h:outputLabel id="accountTouristEmailSecondaryLabel" value ="#{bundle['staff.emailSecondary.label']}" style="font-weight: bold"/>
                            <h:inputText id="emailSec" value="#{staffEditAccountManagedBean.emailSecondary}" required="true" requiredMessage="#{bundle['staff.emailSecondary.required']}"/>
                            <p:message for="emailSec"/>
                            
                        </h:panelGrid>
                    </p:tab>

                </p:tabView>
                
                <br/>
                <h:commandLink id="accountStaffEditButton" value="#{bundle['staff.edit.button']}" action="EditStaffAccount.xhtml" />
            </p:panel>
        </h:form>
    </ui:define>
    
</ui:composition>

